﻿namespace Gamelight.Input
{
	public enum EventType
	{
		MouseDown,
		MouseUp,
		MouseMove,
		MouseLeave,
		MouseEnter,
		KeyDown,
		KeyUp
	}

	public enum MouseButton
	{
		Left,
		Right
	}

	public enum Key
	{
		None = 0,
		A = 1,
		B = 2,
		C = 3,
		D = 4,
		E = 5,
		F = 6,
		G = 7,
		H = 8,
		I = 9,
		J = 10,
		K = 11,
		L = 12,
		M = 13,
		N = 14,
		O = 15,
		P = 16,
		Q = 17,
		R = 18,
		S = 19,
		T = 20,
		U = 21,
		V = 22,
		W = 23,
		X = 24,
		Y = 25,
		Z = 26,
		Num0 = 30,
		Num1 = 31,
		Num2 = 32,
		Num3 = 33,
		Num4 = 34,
		Num5 = 35,
		Num6 = 36,
		Num7 = 37,
		Num8 = 38,
		Num9 = 39,

		F1 = 41,
		F2 = 42,
		F3 = 43,
		F4 = 44,
		F5 = 45,
		F6 = 46,
		F7 = 47,
		F8 = 48,
		F9 = 49,
		F10 = 50,
		F11 = 51,
		F12 = 52,

		NumPad0 = 60,
		NumPad1 = 61,
		NumPad2 = 62,
		NumPad3 = 63,
		NumPad4 = 64,
		NumPad5 = 65,
		NumPad6 = 66,
		NumPad7 = 67,
		NumPad8 = 68,
		NumPad9 = 69,

		Up,
		Down,
		Left,
		Right,
		Enter,
		Escape,
		Space,
		Tab,
		Shift,
		Control,
		Backspace,
		Home,
		End,
		Insert,
		Delete,
		PageUp,
		PageDown,
		Semicolon,
		Equals,
		Comma,
		Hyphen,
		Period,
		Slash,
		Tilde,
		BracketOpen,
		Backslash,
		BracketClose,
		Apostrophe,

		Break,
		NumLock,
		ScrollLock,
		PrintScreen,
		WindowsKey,
		InvokeContextMenu,

		KeyboardMuteButton,
		KeyboardVolumeDownButton,
		KeyboardVolumeUpButton,
		KeyboardMusicStopButton,
		KeyboardMusicPlayPauseButton,

		Unknown = 32767,
	}

	public sealed class InputEvent
	{
		internal static InputEvent CreateMouseDownEvent(MouseButton button, int x, int y)
		{
			return new InputEvent() { Type = EventType.MouseDown, X = x, Y = y, Button = button };
		}

		internal static InputEvent CreateMouseUpEvent(MouseButton button, int x, int y)
		{
			return new InputEvent() { Type = EventType.MouseUp, X = x, Y = y, Button = button };
		}

		internal static InputEvent CreateMouseMoveEvent(int x, int y)
		{
			return new InputEvent() { Type = EventType.MouseMove, X = x, Y = y };
		}

		internal static InputEvent CreateMouseEnterEvent(int x, int y)
		{
			return new InputEvent() { Type = EventType.MouseEnter, X = x, Y = y };
		}

		internal static InputEvent CreateMouseLeaveEvent(int x, int y)
		{
			return new InputEvent() { Type = EventType.MouseLeave, X = x, Y = y };
		}

		internal static InputEvent CreateKeyDownEvent(Key key)
		{
			return new InputEvent() { Type = EventType.KeyDown, Key = key };
		}

		internal static InputEvent CreateKeyUpEvent(Key key)
		{
			return new InputEvent() { Type = EventType.KeyUp, Key = key };
		}

		private InputEvent() { }

		public Key Key { get; private set; }
		public EventType Type { get; private set; }
		public MouseButton Button { get; private set; }
		public int X { get; private set; }
		public int Y { get; private set; }
	}
}
